import { Controller } from 'egg';

export default class BaseController extends Controller {
  protected ok(data: any) {
    const { ctx } = this;
    return (ctx.body = {
      code: 0,
      result: data,
    });
  }

  protected error(msg?: string) {
    const { ctx } = this;
    return (ctx.body = {
      code: -1,
      message: msg,
    });
  }
}
